<?php
namespace app\qywz\controller;
class Admin extends Base{
    public function __construct(){
        parent::__construct();
        $this->checkLogin();
        $end_time = m('Userxiangmu','c')->check($this->userinfo['id'], 5);
        if(!$end_time){
          r(url('bbs/userxiangmu/pay',['id'=>5]));
        }
        $this->assign('page_title','企业网站');
    }
    //首页
    public function index(){
      $db = db([
        'host'   => '47.107.64.194',
        'user'   => 'web_mayibang_co',
        'pwd'    => 'web_mayibang_co',
        'dbname' => 'web_mayibang_co',
        'charset' => 'utf8mb4',
      ]);
      $rs = $db->query('select * from admin_user where website_id=?',[$this->userinfo['id']],1);

      $arr = explode(".",DOMAIN);
      $domain = "{$this->userinfo['id']}.web.{$arr[count($arr)-2]}.{$arr[count($arr)-1]}";

      if(!$rs){
        $data = [
          'website_id' => $this->userinfo['id'],
          'username' => "admin",
          'domain' => $domain,
          'password' => com_password("123456"),
        ];
        $id = $db->insert('admin_user', $data);
        $rs = $db->find('admin_user',$id);
      }
      $this->fetch(['info'=>$rs,'domain'=>$domain],'','layadmin');
    }
}
?>
